package com.dts.servlet;

import com.dts.dao.GoodDao;
import com.dts.entity.Good;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

@WebServlet(name = "list", urlPatterns = "/list")
public class ListServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws jakarta.servlet.ServletException, IOException {
        List<Good> goods = GoodDao.getGoods();
        request.setAttribute("goods", goods);
        request.getRequestDispatcher("/list.jsp").forward(request, response);
    }
}
